package Adapter;

import java.util.List;

import com.example.quanlithuchi.R;

import InterFaceIModel.ILoaiThuChi;
import ViewHoder.LoaiThuChiHoder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class LoaiThuChiAdapter extends ArrayAdapter<ILoaiThuChi> {

	Context context;
	int layout;
	LoaiThuChiHoder hoder;
	List<ILoaiThuChi>list;
	public LoaiThuChiAdapter(Context context, int textViewResourceId,
			List<ILoaiThuChi> objects) {
		super(context, textViewResourceId, objects);
		this.context=context;
		this.layout=textViewResourceId;
		this.list=objects;
		// TODO Auto-generated constructor stub
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView==null) {
			hoder=new LoaiThuChiHoder();
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView=inflater.inflate(layout, parent,false);
			hoder.txtLoaiThuChi=(TextView) convertView.findViewById(R.id.txttenloaithuchi_item);
			hoder.txtGhiChuLoaiThuChi=(TextView) convertView.findViewById(R.id.txtghichuloaithuchi_item);
			convertView.setTag(hoder);
			
		} else {
            hoder=(LoaiThuChiHoder) convertView.getTag();
           
		}
		ILoaiThuChi loaiThuChi=list.get(position);
		 hoder.txtLoaiThuChi.setText(loaiThuChi.getTenLoai());
		 hoder.txtLoaiThuChi.setTag(loaiThuChi);
		 hoder.txtGhiChuLoaiThuChi.setText(loaiThuChi.getGhichu());
		 convertView.setPadding(5, 5, 5, 5);
		 return convertView;
	}
    
	
}
